from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    RegisterView,
    LoginView,
    UserDetailView,
    InterviewDetailView,
    PublicJobListView,
    PublicJobDetailView,
    JobApplicationCreateView,
    UserApplicationListView,
    JobPostingViewSet,
    VideoQuestionViewSet,
    InterviewTemplateViewSet,
    JobApplicationViewSet,
    VoiceProfileViewSet,
    SynthesizedAudioViewSet,
    # 面试相关视图
    InterviewResumeView,
    InterviewSelfIntroductionView,
    InterviewLogicQuestionsView,
    InterviewLogicAnswersView,
    InterviewVideoQuestionsView,
    InterviewVideoAnswersView,
    InterviewResultsView,
    HRInterviewManagementView,
    InterviewStatusCheckView,
    JobApplicationStatisticsView,
    # 报告相关视图
    GenerateInterviewReportView,
    HRReportReviewView,
    BatchApprovalView,
    # 语音相关视图
    get_voice_profiles_for_interview,
    synthesize_audio_for_question,
    # 表情分析相关视图
    analyze_video_api,
    analyze_video_async_api,
    get_video_analysis_result,
    list_video_analyses,
    # 音频分析相关视图
    get_audio_analysis_detail,
    get_video_answer_audio_analysis,
    get_interview_audio_summary,
    list_audio_analyses,
    # 简历匹配相关视图
    ResumeMatchView,
)

router = DefaultRouter()
router.register(r'postings', JobPostingViewSet, basename='jobposting')
router.register(r'video-questions', VideoQuestionViewSet, basename='videoquestion')
router.register(r'templates', InterviewTemplateViewSet, basename='interviewtemplate')
router.register(r'job-applications', JobApplicationViewSet, basename='jobapplication')
router.register(r'voice-profiles', VoiceProfileViewSet, basename='voiceprofile')
router.register(r'synthesized-audios', SynthesizedAudioViewSet, basename='synthesizedaudio')

# URL配置
urlpatterns = [
    # 认证相关URL
    path('auth/register/', RegisterView.as_view(), name='register'),
    path('auth/login/', LoginView.as_view(), name='login'),
    path('auth/me/', UserDetailView.as_view(), name='user-detail'),
    
    # HR面试管理URL
    path('interviews/<int:interview_id>/', InterviewDetailView.as_view(), name='interview-detail'),
    
    # 候选人公开职位URL
    path('public/jobs/', PublicJobListView.as_view(), name='public-job-list'),
    path('public/jobs/<int:job_id>/', PublicJobDetailView.as_view(), name='public-job-detail'),
    
    # 候选人申请相关URL
    path('jobs/<int:job_id>/apply/', JobApplicationCreateView.as_view(), name='job-apply'),
    path('my-applications/', UserApplicationListView.as_view(), name='my-applications'),
    
    # 面试相关URL
    path('interview/<int:application_id>/resume/', InterviewResumeView.as_view(), name='interview-resume'),
    path('interview/<int:application_id>/self-introduction/', InterviewSelfIntroductionView.as_view(), name='interview-self-intro'),
    path('interview/<int:application_id>/logic-questions/', InterviewLogicQuestionsView.as_view(), name='interview-logic-questions'),
    path('interview/<int:application_id>/logic-answers/', InterviewLogicAnswersView.as_view(), name='interview-logic-answers'),
    path('interview/<int:application_id>/video-questions/<str:category>/', InterviewVideoQuestionsView.as_view(), name='interview-video-questions'),
    path('interview/<int:application_id>/video-answers/<str:category>/', InterviewVideoAnswersView.as_view(), name='interview-video-answers'),
    path('interview/<int:application_id>/results/', InterviewResultsView.as_view(), name='interview-results'),
    path('interview/<int:application_id>/status/', InterviewStatusCheckView.as_view(), name='interview-status'),
    path('hr/interview/<int:application_id>/management/', HRInterviewManagementView.as_view(), name='hr-interview-management'),
    
    # HR申请管理相关URL
    path('job-applications/statistics/', JobApplicationStatisticsView.as_view(), name='job-applications-statistics'),
    
    # 报告相关URL
    path('interview/<int:application_id>/generate-report/', GenerateInterviewReportView.as_view(), name='generate-interview-report'),
    path('hr/reports/<int:report_id>/', HRReportReviewView.as_view(), name='hr-report-review'),
    path('hr/batch-approval/', BatchApprovalView.as_view(), name='batch-approval'),
    
    # 语音相关URL
    path('interview/<int:interview_id>/voice-profiles/', get_voice_profiles_for_interview, name='interview-voice-profiles'),
    path('questions/<int:question_id>/synthesize-audio/<int:voice_profile_id>/', synthesize_audio_for_question, name='synthesize-audio'),
    
    # 表情分析相关URL
    path('api/video/analyze/', analyze_video_api, name='analyze_video'),
    path('api/video/analyze-async/', analyze_video_async_api, name='analyze_video_async'),
    path('api/video/result/<int:analysis_id>/', get_video_analysis_result, name='video_analysis_result'),
    path('api/video/list/', list_video_analyses, name='video_analyses_list'),
    
    # 音频分析相关URL
    path('audio-analysis/<int:audio_analysis_id>/', get_audio_analysis_detail, name='audio-analysis-detail'),
    path('video-answers/<int:video_answer_id>/audio-analysis/', get_video_answer_audio_analysis, name='video-answer-audio-analysis'),
    path('interview/<int:application_id>/audio-summary/', get_interview_audio_summary, name='interview-audio-summary'),
    path('audio-analyses/', list_audio_analyses, name='audio-analyses-list'),
    
    # 简历匹配相关URL
    path('resume-match/', ResumeMatchView.as_view(), name='resume-match'),
    
    # 包含router的URL
    path('', include(router.urls)),
] 